#include "D3D9_PCH.h"
#include "D3D9CameraPerspective.h"


CD3DCameraPerspective::CD3DCameraPerspective( const CD3DWorld* pSubject )
	: CD3DCamera( pSubject )
{
	setProjection( 45, 1.333f, 1.f, 1000.f );
}


CD3DCameraPerspective::~CD3DCameraPerspective(void)
{
}


void CD3DCameraPerspective::setProjection( FLOAT fFovY, FLOAT fAspectRatio, FLOAT fNear, FLOAT fFar ) {

	m_fFovY = D3DXToRadian(fFovY);
	m_fAspectRatio = fAspectRatio;
	m_fNear = fNear;
	m_fFar = fFar;

	computeProjectionMatrix();
}

void CD3DCameraPerspective::setFov( FLOAT fFovY ) {
	m_fFovY = D3DXToRadian(fFovY);
	computeProjectionMatrix();
}

void CD3DCameraPerspective::setAspectRatio( FLOAT fAspectRatio ) { 
	m_fAspectRatio = fAspectRatio;
	computeProjectionMatrix();
}

void CD3DCameraPerspective::computeProjectionMatrix() {
	D3DXMatrixPerspectiveFovLH( &m_matProjection, m_fFovY, m_fAspectRatio, m_fNear, m_fFar );
}